<?php
header("content-type:text/html; charset=utf-8");
session_start();
require_once 'inc/config.php';
require_once 'inc/classes/db.php';
require_once 'inc/classes/template.php';
require_once 'inc/classes/util.php';
require_once 'include/staticdata.php';
require_once 'include/pagination.php';

$gTemplate['templateDir'] = 'templates/';
$gTemplate['leftDelimiter'] = '{';
$gTemplate['rightDelimiter'] = '}';
$tpl = new Template( $gTemplate );
$db  = new db( $gDb );
util::gpc( );

$tpl->assign('topnav', 	StaticData::getMenuData());
$tpl->assign('smallnav',StaticData::getSmallNav());
$tpl->assign('sort', 	StaticData::getSort());
$tpl->assign('lang',	include('include/lang.php'));

$tpl->assign('page', $page );

$id = intval ( $_GET['id'] );
if( !$id ) {
	header('location: news.php');
	exit( );
}
$data = $db->fetchrow('select a.catename,b.* from '.$gDb['prefix'].'news b left join '.$gDb['prefix'].'category a on a.id=b.catid where b.id='.$id);
$page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
$pages = explode('[page]',$data['content']);
$countpages = count( $pages );
$headerExtrea = '<script src="js/jquery.js" type="text/javascript"></script><script src="js/utils.js" type="text/javascript"></script>';
$tpl->assign('title', '爱淘之家淘宝精品 _网络购物网赚新动力');
$tpl->assign('HeaderExtrea', $headerExtrea);

if( $countpages  > 1 )
{
	$pager = new Pagination( $countpages, 1 );
	$tpl->assign('pagination', $pager->getPagination());
}
if( $countpages > 1) $data['content'] = $pages[$page-1];
$tpl->assign('sess',$_SESSION);
$tpl->assign('data',$data);
$tpl->display( 'news_detail.tpl' );